-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Encode dep graph edges directly from the previous graph when promoting #122070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
r? @cjgillot |
This comment has been minimized.
This comment has been minimized.
de02827 to
34a3025
Compare
This comment has been minimized.
This comment has been minimized.
34a3025 to
d9fe043
Compare
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Encode dep graph edges directly from the previous graph when promoting This encodes dep graph edges directly from the previous graph when promoting nodes from a previous session, avoiding allocations / copies. Based on rust-lang#122064 and rust-lang#116375. <table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check:unchanged</td><td align="right">0.4177s</td><td align="right">0.4072s</td><td align="right">💚 -2.52%</td></tr><tr><td>🟣 <b>hyper</b>:check:unchanged</td><td align="right">0.1430s</td><td align="right">0.1420s</td><td align="right"> -0.69%</td></tr><tr><td>🟣 <b>regex</b>:check:unchanged</td><td align="right">0.3106s</td><td align="right">0.3038s</td><td align="right">💚 -2.19%</td></tr><tr><td>🟣 <b>syn</b>:check:unchanged</td><td align="right">0.5823s</td><td align="right">0.5688s</td><td align="right">💚 -2.33%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check:unchanged</td><td align="right">1.3992s</td><td align="right">1.3692s</td><td align="right">💚 -2.14%</td></tr><tr><td>Total</td><td align="right">2.8528s</td><td align="right">2.7910s</td><td align="right">💚 -2.17%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9803s</td><td align="right">💚 -1.97%</td></tr></table>
|
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (ae110c4): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 649.968s -> 649.736s (-0.04%) |
d9fe043 to
bb9f99c
Compare
cjgillot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you provide an explanation where the gains come from? I suspected we remove the need to decode the edges, but that's not it.
| self.record_edge( | ||
| dep_node_index, | ||
| prev_graph.index_to_node(prev_index), | ||
| prev_graph.fingerprint_by_index(prev_index), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep the let-bindings for those two? They are computed by promote IIUC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to keep them close to their use in promote.
| if let Some(record_graph) = &mut record_graph.try_lock() { | ||
| record_graph.push(index, node.node, &node.edges); | ||
| } | ||
| let edges = edges(self); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this call inside the closure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted the closure construction to be able to be optimized out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Could you add a comment to justify the outline?
| node: DepNode, | ||
| fingerprint: Fingerprint, | ||
| prev_index: SerializedDepNodeIndex, | ||
| prev_index_to_index: &mut IndexVec<SerializedDepNodeIndex, Option<DepNodeIndex>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why &mut?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about uniqueness, but it doesn't help here. I've changed it to &.
| let edges = prev_graph | ||
| .edge_targets_from(prev_index) | ||
| .map(|i| prev_index_to_index[i].unwrap()) | ||
| .collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR avoids this copy and allocation into EdgesVec.
bb9f99c to
4704852
Compare
|
@rustbot ready |
|
@bors r+ |
| } | ||
|
|
||
| #[inline] | ||
| fn encode_promoted<D: Deps>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment on this method, to explain the difference with encode?
| let stat = stats.entry(kind).or_insert(Stat { kind, node_counter: 0, edge_counter: 0 }); | ||
| stat.node_counter += 1; | ||
| stat.edge_counter += edge_count as u64; | ||
| outline(move || { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment to justify the outline?
| if let Some(record_graph) = &mut record_graph.try_lock() { | ||
| record_graph.push(index, node.node, &node.edges); | ||
| } | ||
| let edges = edges(self); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Could you add a comment to justify the outline?
| } | ||
|
|
||
| #[inline] | ||
| fn promote_node( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you document this method? and the difference with encode_node?
|
@bors r- Actually, could you add a few comments there and there? |
4704852 to
aa9c9a3
Compare
|
@oli-obk Do you mind approving for me? |
|
@bors r=cjgillot |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (4563f70): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 668.072s -> 669.208s (0.17%) |
|
The improvements obviously overweigh the single regression. @rustbot label: +perf-regression-triaged |
This encodes dep graph edges directly from the previous graph when promoting nodes from a previous session, avoiding allocations / copies.
Based on #122064 and #116375.